/* 
 * File:   AudioManager.h
 * Author: RedEyedKiller
 *
 * Created on 26 Αύγουστος 2011, 8:50 μμ
 */

#ifndef AUDIOMANAGER_H
#define	AUDIOMANAGER_H

#include <list>

namespace al
{

class AudioSource;
class AudioCore;
class StreamSource;

class AudioManager
{
public:
    AudioManager();

    virtual ~AudioManager();

    /**
     * Update streams.
     * @return 
     */
    bool Update();

    /**
     * Returns a newly created audio source.
     * @return 
     */
    AudioSource* CreateSource();

    /**
     * Deallocates an audio source.
     * @param toKill
     */
    void KillSource(AudioSource* toKill);

    StreamSource* CreateStream();

    void KillStream(StreamSource* toKill);

    void KillOneTimeSounds();

    /**
     * All paused sources and streams (not stopped) start playing.
     */
    void PlayAll();

    /**
     * All playing sources and streams pause;
     */
    void PauseAll();

    //global grain streams
    //global grain sources

private:

    /**
     * Created a new valid id to be used as openal source id.
     * @return 
     */
    unsigned int CreateSourceID();

    typedef std::list<AudioSource*> AudioList;
    typedef AudioList::iterator AudioListIter;
    typedef AudioList::const_iterator AudioListConstIter;
    AudioList sources;

    typedef std::list<StreamSource*> StreamList;
    typedef StreamList::iterator StreamListIter;
    typedef StreamList::const_iterator StreamListConstIter;
    StreamList streams;

};

};
#endif	/* AUDIOMANAGER_H */

